package com.warningrc.system.lang;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

public final class WarningLogger {
	private static Map<Class<?>, WarningLogger> cache = new HashMap<Class<?>, WarningLogger>();
	private Logger log;

	private WarningLogger(Logger log) {
		this.log = log;
	}

	public static WarningLogger getWarningLogger(Class<?> cla) {
		WarningLogger logger = null;
		cla = cla == null ? Object.class : cla;
		logger = cache.get(cla);
		if (logger == null) {
			logger = new WarningLogger(Logger.getLogger(cla));
			cache.put(cla, logger);
		}
		return logger;
	}

	public void info(String message) {
		if (log.isInfoEnabled())
			log.info(message);
	}

	public void info(String message, Throwable throwable) {
		if (log.isInfoEnabled())
			log.info(message, throwable);
	}

	public void debug(String message) {
		if (log.isDebugEnabled())
			log.debug(message);
	}

	public void debug(String message, Throwable throwable) {
		if (log.isDebugEnabled())
			log.debug(message, throwable);
	}

	public void trace(String message) {
		if (log.isTraceEnabled())
			log.trace(message);
	}

	public void trace(String message, Throwable throwable) {
		if (log.isTraceEnabled())
			log.trace(message, throwable);
	}

	public void error(String message) {
		log.error(message);
	}

	public void error(String message, Throwable throwable) {
		log.error(message, throwable);
	}

	public void warn(String message) {
		log.warn(message);
	}

	public void warn(String message, Throwable throwable) {
		log.warn(message, throwable);
	}

	public void fatal(String message) {
		log.fatal(message);
	}

	public void fatal(String message, Throwable throwable) {
		log.fatal(message, throwable);
	}

	public static void main(String[] args) {
		System.out.println(WarningLogger.getWarningLogger(WarningLogger.class));
	}
}
